<?php

namespace common\logics\shop;

use Yii;
use common\models\user\UserHistory;

/**
 * 标准化产品单元数据模型（SPU）
 * 
 * @author emhome<emhome@163.com>
 * @since 2.0
 */
class StandardProductUnit extends \common\models\shop\ShopProduct {

    /**
     * {@inheritdoc}
     */
    public function afterFind() {
        if (Yii::$app->user->id) {
            UserHistory::record(Yii::$app->user->id, UserHistory::MODEL_SPU, $this->id);
        }
        parent::afterFind();
    }

    /**
     * @inheritdoc
     */
    protected function getCustormService() {
        return [
            'user_id' => 1,
            'name' => '优越定制客服',
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function fields() {
        return [
            'id',
            'name',
            'art_no',
            'slogan',
            'description',
            'thumb',
            'album',
            'price' => 'memberPrice',
            'market_price' => 'marketPrice',
            'newest',
            'free_shipping' => 'freeShipping',
            'collected',
            'weblink',
            'share_data' => 'shareData',
            'custorm_service' => 'custormService',
        ];
    }

}
